/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: YKH
 * Date: 2022-10-11
 * Time: 20:39
 */
import java.util.Scanner;

/**
 * 求两个 字符串的最长公共字串的长度
 */
public class Main3{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String a = scan.nextLine();
        String b = scan.nextLine();
        int ret = commonLength(a,b);
        System.out.println(ret);
    }
    public static int commonLength(String s1, String s2){
        int len1 = s1.length();
        int len2 = s2.length();
        int max = 0;
        //初始化f[i][j]
        int[][] f = new int[len1+1][len2+1];
        for(int i=0;i<=len1;i++){
            for(int j=0;j<=len2;j++){
                f[i][j] = 0;
            }
        }
        //若是s1[i] == s2[j]，F[i,j] = F[i-1,j-1] + 1
        for(int i=1;i<=len1;i++){
            for(int j=1;j<=len2;j++){
                if(s1.charAt(i-1) == s2.charAt(j-1)){
                    f[i][j] = f[i-1][j-1] + 1;
                }
                else {
                    f[i][j] = 0;
                }
            }
        }
        //求最大值
        for(int i=0;i<=len1;i++){
            for(int j=0;j<=len2;j++){
                if(f[i][j] > max){
                    max = f[i][j];
                }
            }
        }
        return max;
    }
}
